import { SerializeStream } from "../Serialize/SerializeStream";
import { SeqHandlerIdHelper } from "./SeqHandlerIdHelper";
import {
  StreamDispacher,
  StreamDispacherDataType
} from "../../flash/events/StreamDispacher";
import { HandlerId } from "./HandlerId";
// import { PropertyChangeEvent } from "../../mx/events/PropertyChangeEvent";
type int = number;
//class MessageHead

export class MessageHead extends StreamDispacher {
  constructor() {
    super([
      {
        key: "command",
        type: StreamDispacherDataType.Size
      },
      {
        key: "channelId"
      },
      {
        key: "fromIds"
      },
      {
        key: "toIds"
      }
    ]);
  }
  public __write(stream: SerializeStream) {
    super.__write(stream);
    SeqHandlerIdHelper.write(stream, this.fromIds);
    SeqHandlerIdHelper.write(stream, this.toIds);
  }

  public __read(stream: SerializeStream) {
    super.__read(stream);
    this.fromIds = SeqHandlerIdHelper.read(stream);
    this.toIds = SeqHandlerIdHelper.read(stream);
  }

  public command!: int;
  public channelId!: int;
  public fromIds!: Array<HandlerId>;
  public toIds!: Array<HandlerId>;
}
